import java.io.*;
import java.util.*;

/******************************************************************
 * public class FileLoader
 * public void setFileName (File file)
 * public void setFileName (String file_name)
 * private void loadFile ()
 * public Hashtable getHashTable ()
 *
 ******************************************************************/

public class SectorFileLoader  {

    private Hashtable tickHashTable = new Hashtable();
    private File name = null;

    public static void main (String args[]) {
	String file_name = args[0];
	String data_dir = "./Data/Sector/";
	Hashtable f_hashtable = new Hashtable ();
       
	SectorFileLoader fl = new SectorFileLoader ();
	fl.setFileName(data_dir+file_name);
	fl.loadFile();
	f_hashtable = fl.getHashTable();
	//System.out.println(f_hashtable);
    }

    public void setFileName( String file_name )
    {
	name = new File (file_name);
    }

    public Hashtable getHashTable () {
	return tickHashTable;
    }

    public void setFileName( File file )
    {

	name = file;
    }

    public void loadFile () {

        if ( !name.exists() ) {
	    System.out.println("File:"+name.getName()+" not found!");
	    return;
	}

	if ( name.isFile() ) {
	   try {
               RandomAccessFile r =  new RandomAccessFile( name, "r" );
               String text;

               while( ( text = r.readLine() ) != null ) {
		   //System.out.println(text);
		   StringTokenizer tokens = new StringTokenizer(text, "\t");
		   while (tokens.hasMoreTokens()) {
		       tickHashTable.put(tokens.nextToken(), tokens.nextToken());
		   }
	       }

	       r.close();
	   }
	   catch( IOException e ) {

	   }
       }
    }
}



